﻿Chenxin.UI.BusinessReportBide = Chenxin.extend(Chenxin.UI.PageCommon, {
    autoInitForm: false,
    actionUrl: '/service/logic/BusinessReportBide.ashx',
    createSearch: function() {
        return new Chenxin.UI.BusinessReportBideSearch({
            scope: this
        });
    },
    showDetails: function(op, btype, ctype) {
        if (!this.detailsWin) {
            this.detailsWin = new Chenxin.UI.DetailsWin({
                id: 'x_details_win',
                actionUrl: this.actionUrl
            });
        }
        this.detailsWin.show();

        this.detailsWin.setTitle('详细信息');
        this.detailsWin.grid.baseParam.op = op;
        this.detailsWin.grid.param.btype = btype;
        this.detailsWin.grid.param.ctype = ctype;
        Chenxin.apply(this.detailsWin.grid.param, this.search.getParamJson());
        this.detailsWin.grid.reload('',0);
    }
});

Chenxin.UI.DetailsWin = Chenxin.extend(Chenxin.UI.Win, {
    id: '',
    actionUrl: '',
    width: 680,
    hasFoot: true,
    height: 360,
    content: '<div id="x_details_grid"></div>',
    createBtn: function() {
        return [{
            text: '关闭',
            handler: this.hide
}]
        },
        createGrid: function() {
            if (this.grid) {
                return;
            }
            this.grid = new Chenxin.UI.JsonGrid({
                baseParam: { op: '' },
                autoLoad: false,
                actionUrl: this.actionUrl,
                id: 'x_details_grid',
                renderTo: 'x_details_grid',
                hasCheckBox: false,
                cellBorder: true,
                modelId: 'a',
                scope: this,
                height: 311,
                hasTitle: false,
                columns: {
                    ContractCode: { head: '合同编号', width: 150 },
                    HouseCode: { head: '房源编号', width: 200 },
                    HouseAddress: { head: '房源地址', width: 300 },
                    Area: { head: '面积', width: 100 },
                    BargainPrice: { head: '成交金额', width: 100 },
                    RealCommision: { head: '营业收入', width: 100 }
                }
            });
        },
        initComponent: function() {
            Chenxin.UI.DetailsWin.superclass.initComponent.call(this);
            this.createGrid();
        }
    });

/*
* 查询面板
*/
Chenxin.UI.BusinessReportBideSearch = Chenxin.extend(Chenxin.UI.SearchCommon, {
    id: 'BusinessReport_search',
    createComboList: function() {
        var _this = this;
        var combl = new Chenxin.UI.StructComboList({
            tbxWidth: 45
        });

        var cmbDateType = new Chenxin.UI.Combo({
            containerId: '#datetype',
            name: 'datetype',
            tbxWidth: 55,
            addPleaseSelected: false,
            items: [{ val: 'ContractDate', txt: '成交日期' }, { val: 'ArchivementDate', txt: '业绩归属'}]
        });

        var region = new Chenxin.UI.ParameterCombo({
            name: 'region',
            containerId: '#region',
            key: 'System.Region',
            tbxWidth: 45,
            inModelType: 'txt'
        });

        var structs = combl.comboList;
        structs.push(cmbDateType);
        structs.push(region);
        return structs;
    },
    initEvent: function() {
        var _this = this;
        $('#export').click(function() {
            Chenxin.Msg.Loading.show();
            Chenxin.ajax({
                type: "get",
                dataType: "json",
                url: '/service/logic/BusinessReportBide.ashx',
                data: { op: 'checkpermit', code: 'export' },
                onSuccess: function(data) {
                    Chenxin.Msg.Loading.hide();
                    Chenxin.Fn.exportToExcel($('#search_table').html());
                }
            });
        });
        /*********事件：检索按钮*********/
        $("#btnSreach").click(function() {
            Chenxin.Msg.Loading.show();
            Chenxin.ajax({
                type: 'get',
                dataType: 'html',
                url: '/service/logic/BusinessReportBide.ashx?op=getlist',
                data: _this.getParamJson(),
                onSuccess: function(data, msg) {
                    $('#search_table').empty();
                    $('#search_table').html(data.html);
                    Chenxin.Msg.Loading.hide();
                }
            });
        });
        $('.a_details').live('click', function() {
            _this.scope.showDetails('getdetails', $(this).attr('btype'), $(this).attr('ctype'));
        });
    }
});

getcity = true; //设置需要获取城市下拉框数据

$(function() {
    var objPg = new Chenxin.UI.BusinessReportBide();
});